import { useResponseSuccess } from '~/utils/response';

export default eventHandler(async (event) => {
  const query = getQuery(event);
  const { date, viewMode = 'month' } = query;

  // 模拟调度数据
  const schedules = [
    {
      id: '1',
      resourceId: '1',
      resourceName: '豪华套房',
      customerName: '张三',
      date: '2024-01-15',
      startTime: '14:00',
      endTime: '16:00',
      status: 'CONFIRMED',
      remark: 'VIP客户',
    },
    {
      id: '2',
      resourceId: '2',
      resourceName: '温泉池',
      customerName: '李四',
      date: '2024-01-15',
      startTime: '15:00',
      endTime: '17:00',
      status: 'PENDING',
      remark: '',
    },
    {
      id: '3',
      resourceId: '3',
      resourceName: 'VIP包间',
      customerName: '王五',
      date: '2024-01-15',
      startTime: '18:00',
      endTime: '20:00',
      status: 'CONFIRMED',
      remark: '生日宴请',
    },
    {
      id: '4',
      resourceId: '4',
      resourceName: '数字会议室',
      customerName: '赵六',
      date: '2024-01-16',
      startTime: '09:00',
      endTime: '11:00',
      status: 'CONFIRMED',
      remark: '项目会议',
    },
    {
      id: '5',
      resourceId: '5',
      resourceName: '按摩服务',
      customerName: '钱七',
      date: '2024-01-16',
      startTime: '16:00',
      endTime: '17:00',
      status: 'PENDING',
      remark: '',
    },
  ];

  // 根据日期过滤
  const filteredSchedules = date
    ? schedules.filter((s) => s.date === date)
    : schedules;

  return useResponseSuccess({
    schedules: filteredSchedules,
    total: filteredSchedules.length,
  });
});
